package cn.dengta.webapp.user.entity;

import java.util.Date;
import java.util.Map;

import cn.dengta.common.util.Formats;
import cn.dengta.webapp.base.entity.TimeBasedEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.*;

/**
 * 用户禁用日志
 *
 * @author lgy
 * @since 2022-08-08
 */
@Setter
@Getter
@Accessors(chain = true)
public class UserFreezeLog extends TimeBasedEntity {

	/** 操作用户Id */
	private Long addUserId;
	/** 操作用户昵称 */
	private String nickname;
	/** 备注信息 */
	private String remark;
	/** 冻结时间 */
	private Date freezeTime;

	public UserFreezeLog init(UserFreezeLog input, Date now) {
		this.id = X.expectNotNull(id, input.id);
		this.addUserId = input.addUserId;
		this.remark = StringUtil.toString(input.remark);
		this.freezeTime = X.expectNotNull(input.freezeTime, now);
		this.nickname = StringUtil.toString(input.nickname);
		super.initTime(now);
		return this;
	}

	public static Map<String, Object> asEmbed(UserFreezeLog source) {
		return asEmbed(source, t -> CollectionUtil.ofHashMap("id", t.getId(), "userId", t.getAddUserId(), "nickname", t.getNickname(),
				"remark", t.getRemark(), "operationTime_", Formats.formatDefDate(t.getUpdateTime())));
	}

	public static final String ID = "id";
	public static final String ADD_USER_ID = "add_user_id";
	public static final String REMARK = "remark";
	public static final String FREEZE_TIME = "freeze_time";
	public static final String ADD_TIME = "add_time";
	public static final String UPDATE_TIME = "update_time";

}
